﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using SilverTile.Sprites;

namespace SilverTile.Xaml
{
    public class SpawnPoint : FrameworkElement
    {

        public SpawnPoint()
        { }

        public static readonly DependencyProperty SpriteTypeProperty = DependencyProperty.Register("SpriteType", typeof(SpriteAnimation), typeof(SpawnPoint), null);
        public SpriteAnimation SpriteType
        {
            get { return (SpriteAnimation)GetValue(SpriteTypeProperty); }
            set { SetValue(SpriteTypeProperty, value); }
        }

        public static readonly DependencyProperty SpawnRateProperty = DependencyProperty.Register("SpawnRate", typeof(int), typeof(SpawnPoint), null);
        public int SpawnRate
        {
            get { return (int)GetValue(SpawnRateProperty); }
            set { SetValue(SpawnRateProperty, value); }
        }

        public static readonly DependencyProperty SpawnProbabilityProperty = DependencyProperty.Register("SpawnProbability", typeof(int), typeof(SpawnPoint), null);
        public int SpawnProbability
        {
            get { return (int)GetValue(SpawnProbabilityProperty); }
            set { SetValue(SpawnProbabilityProperty, value); }
        }

        public static readonly DependencyProperty SpriteClassNameProperty = DependencyProperty.Register("SpriteClassName", typeof(string), typeof(SpawnPoint), null);
        public string SpriteClassName
        {
            get { return (string)GetValue(SpriteClassNameProperty); }
            set { SetValue(SpriteClassNameProperty, value); }
        }

        public static readonly DependencyProperty SpawnAtStartupProperty = DependencyProperty.Register("SpawnAtEnter", typeof(Boolean), typeof(SpawnPoint), null);
        public Boolean SpawnAtStartup
        {
            get { return (Boolean)GetValue(SpawnAtStartupProperty); }
            set { SetValue(SpawnAtStartupProperty, value); }
        }


        internal TimeSpan TimeSinceLastSpawn { get; set; }

        internal SpriteTile Tile { get; set; }

        public Boolean CanSpawn
        {
            get { return TimeSinceLastSpawn.TotalSeconds > SpawnRate; }
        }
        
    }
}
